package Q27;

/**
 * 移除元素
 * @author 23737
 * @time 2021.12.2
 */
public class Test {
    public static void main(String[] args) {

    }
}

class Solution {
    public int removeElement(int[] nums, int val) {
        int j = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] != val){
                nums[j] = nums[i];
                j++;
            }
        }
        return j;
    }
}